package com.apex.gateway;

import com.apex.shared.core.utils.IpUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

/**
 * Apex Gateway 应用程序
 *
 * @author MoNaiHui
 */
@SpringBootApplication
public class ApexGatewayApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(ApexGatewayApplication.class, args);
        Environment env = application.getEnvironment();
        String port = env.getProperty("server.port");
        String contextPath = env.getProperty("server.servlet.contextPath", "");
        String ip = IpUtils.getHostIp();
        
        System.out.println("✅ 网关服务启动成功!");
        System.out.println("🔍 服务访问信息:");
        System.out.println("➭ 本地访问: http://localhost:" + port + contextPath);
        System.out.println("➭ 外网访问: http://" + ip + ":" + port + contextPath);
        // 判断接口文档是否开启 
        if (Boolean.parseBoolean(env.getProperty("knife4j.gateway.enabled", "false"))) {
            System.out.println("➭ 接口文档: http://" + ip + ":" + port + contextPath + "/doc.html");
        }
    }
    
}